<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'base.item.class.php');

class ContactusBase extends BaseItemBase {
	
	//constructor
	function ContactusBase() {
		parent::BaseItemBase();
		
		$this->table = 'pp_contactus';
		$this->prefix = 'contactus_';
		
		$this->search_fields = array('name');
		$this->sort_fields = array('id-');
	}
	
	//methods
	function onAddItemAfter($data_array, $items_id) {
		global $SETTINGS;
		
		$to_name = $SETTINGS['bs_emailname'];
		$to_email_address = $SETTINGS['bs_emailaddress'];
		
		if( $to_email_address == '' && strstr($to_email_address, '@') === false ) {
			return false;	
		}
		
		$name = $data_array['contactus_name'];
		$email = $data_array['contactus_email'];
		$company = $data_array['contactus_company'];
		$telephone = $data_array['contactus_telephone'];
		$address = $data_array['contactus_address'];
		$state = $data_array['contactus_state'];
		$postcode = $data_array['contactus_postcode'];
		
		$from_name = $name;
		$from_email_address = $email;
		
		$email_subject = 'New Contact Us From Website';
		$email_text = 'Name: ' . $name . "\n";
		$email_text .= 'Email: ' . $email . "\n";
		$email_text .= 'Company: ' . $company . "\n";
		$email_text .= 'Telephone: ' . $telephone . "\n";
		$email_text .= 'Address: ' . $address . "\n";
		$email_text .= 'State: ' . $state . "\n";
		$email_text .= 'Postcode: ' . $postcode . "\n";
		
		//util_mail($to_name, $to_email_address, $email_subject, $email_text, $from_name, $from_email_address);
	}
}
//
?>